/*
 * @lc app=leetcode id=28 lang=cpp
 *
 * [28] Implement strStr()
 */
class Solution {
public:
    int strStr(string haystack, string needle) {

        int len = haystack.size();

        int nlen = needle.size();
        if (nlen < 1) {
            return 0;
        }

        int i = 0;
        while(i+nlen <= len) {
            if (haystack.substr(i, nlen) == needle) {
                return i;
            }
            i++;
        }

        return -1;
    }
};

